package test.hook;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Random;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class App {
	
	static ExecutorService es = Executors.newFixedThreadPool(30);
	
	public static void main(String[] args) {
		System.out.println(new SimpleDateFormat("HH:mm:ss").format(new Date()));
		for(int i= 0;i<10;i++) {
			es.execute(new Runnable() {
				
				@Override
				public void run() {
					try {
						Thread.sleep(new Random().nextInt(5)*1000);
					} catch (InterruptedException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}
			});
		}
		es.shutdown();
		Runtime.getRuntime().addShutdownHook(new Thread() {
			@Override
			public void run() {
				System.out.println(new SimpleDateFormat("HH:mm:ss").format(new Date()));
				System.out.println("shut down");
			}
		});
	}

}
